package com.qwt.part_time_api.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.qwt.part_time_api.service.MerchantsService;
import com.qwt.part_time_api.vo.ReleaseMerchantsVo;
import com.qwt.part_time_api.vo.Result;
import com.qwt.part_time_api.vo.TaskDetailVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 君子慎独
 * @create 2022/1/2 0002 21:55
 */
@RestController
@RequestMapping("/merchants")
@Api(tags = {"商家信息"})
public class MerchantsController {

    @Autowired
    private MerchantsService merchantsService;

    /**
     * 查询任务发布商家
     *
     * @param rid 发布商家id
     * @return 商家基本信息
     */
    @GetMapping("/release/{rid}")
    @ApiOperation(value = "发布商家信息", notes = "查询任务发布商家")
    @ApiOperationSupport(author = "Tzeao")
    @ApiResponses(@ApiResponse(code = 200, message = "成功", response = ReleaseMerchantsVo.class))
    public Result release(@PathVariable("rid") Long rid) {
        return merchantsService.findMerchantsById(rid);
    }

    /**
     * 根据商家ID查询任务列表
     *
     * @param rid 商家id 不用名称是考虑到重名问题
     * @return 任务列表
     */
    @GetMapping("/recommend/{rid}")
    @ApiOperation(value = "商家推荐", notes = "根据商家ID查询任务列表")
    @ApiOperationSupport(author = "Tzeao")
    @ApiResponses(@ApiResponse(code = 200, message = "成功", response = TaskDetailVo.class))
    public Result merchantsRecommend(@PathVariable("rid") Long rid) {
        return merchantsService.findTaskListByMerchantsId(rid);
    }
}
